package FileClass;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class CopyFile {
	public static void fileCopy(String src, String dest, boolean move){
		try {
			FileInputStream fis = new FileInputStream(new File(
					src));
			BufferedInputStream bis = new BufferedInputStream(fis);
			// System.out.println(fis.available());
			FileOutputStream fos = new FileOutputStream(new File(
					dest));
			BufferedOutputStream bos = new BufferedOutputStream(fos);
			int read;
			byte [] buff = new byte[10240];
			/** 
			Cach copy 3 
			
			int soByteDocDuoc =0;
			while ((soByteDocDuoc = bis.read(buff)) == buff.length){
				bos.write(buff, 0, soByteDocDuoc);
			}
			*/
			
			/**
			  Cach copy 1 */
			  while (( read = bis.read(buff)) !=-1){
				bos.write(buff, 0, read);
			} 
			
			/**
			  Cach copy 2
			  while ((read = bis.read()) != -1) {
				bos.write(read);
			} */
			bis.close();
			bos.close();
			//if(move) new File(src).delete();
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}
	public static void main(String[] args) {
		CopyFile c = new CopyFile();
		c.fileCopy("", "",true);
	}
}
